<html>
<head><meta charset="utf-8"><title>async vision - status quo · wg-async-foundations · Zulip Chat Archive</title></head>
<h2>Stream: <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/index.html">wg-async-foundations</a></h2>
<h3>Topic: <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/async.20vision.20-.20status.20quo.html">async vision - status quo</a></h3>

<hr>

<base href="https://rust-lang.zulipchat.com">

<head><link href="https://rust-lang.github.io/zulip_archive/style.css" rel="stylesheet"></head>

<a name="227983099"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/async%20vision%20-%20status%20quo/near/227983099" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> tmandry <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/async.20vision.20-.20status.20quo.html#227983099">(Feb 26 2021 at 19:54)</a>:</h4>
<p>So I wanted to start collecting notes and "horror stories" (but also good stories) about async</p>



<a name="227983127"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/async%20vision%20-%20status%20quo/near/227983127" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> tmandry <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/async.20vision.20-.20status.20quo.html#227983127">(Feb 26 2021 at 19:55)</a>:</h4>
<p>but I think it would be too noisy in the main "async vision" topic, so doing that here</p>



<a name="227983198"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/async%20vision%20-%20status%20quo/near/227983198" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> tmandry <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/async.20vision.20-.20status.20quo.html#227983198">(Feb 26 2021 at 19:55)</a>:</h4>
<p>First there are all the <a href="https://nikomatsakis.github.io/wg-async-foundations/conversations/2021-02-12-Twitter-Thread.html">notes</a> from <a href="https://twitter.com/nikomatsakis/status/1359454255971770372">Niko's tweet</a></p>
<div class="inline-preview-twitter"><div class="twitter-tweet"><a href="https://twitter.com/nikomatsakis/status/1359454255971770372"><img class="twitter-avatar" src="https://pbs.twimg.com/profile_images/1110539492706914304/NUeyOrLX_normal.png"></a><p>I'm looking for blog posts or other detailed stories of people using async-await in #rustlang. I'd like to understand their experiences. Particularly curious about people learning Rust and async-await at the same time, maybe coming from other languages. Links?</p><span>- Niko Matsakis (@nikomatsakis)</span></div></div>



<a name="227983498"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/async%20vision%20-%20status%20quo/near/227983498" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> tmandry <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/async.20vision.20-.20status.20quo.html#227983498">(Feb 26 2021 at 19:57)</a>:</h4>
<p>A recent one that comes to mind for me is <a href="https://twitter.com/stuhood/status/1360330437176954880">this tweet</a> about async fn stack sizes and how to prevent stack overflows (it's hard)</p>
<div class="inline-preview-twitter"><div class="twitter-tweet"><a href="https://twitter.com/stuhood/status/1360330437176954880"><img class="twitter-avatar" src="https://pbs.twimg.com/profile_images/552191334467907584/uEkMGreU_normal.jpeg"></a><p><a href="https://twitter.com/rustlang">@rustlang</a> async-using rustaceans: how are you bounding your async-fn stack sizes (see <a href="https://t.co/kAPIMebKQK">https://without.boats/blog/futures-and-segmented-stacks/#segmenting-your-futures-for-fun-and-profit</a>) to avoid overflows? Our approach so far has been guess-and-check with regard to boxing: wondering if there are more rigorous strategies.</p><span>- Stu Hood (@stuhood)</span></div></div>



<a name="227983669"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/async%20vision%20-%20status%20quo/near/227983669" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> tmandry <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/async.20vision.20-.20status.20quo.html#227983669">(Feb 26 2021 at 19:58)</a>:</h4>
<p>And <a href="https://twitter.com/ekuber/status/1347697847462871043">this one</a> (see quoted tweet) about really long compiler error messages</p>
<div class="inline-preview-twitter"><div class="twitter-tweet"><a href="https://twitter.com/ekuber/status/1347697847462871043"><img class="twitter-avatar" src="https://pbs.twimg.com/profile_images/1212821966467420161/Jymc4Y_T_normal.jpg"></a><p>rustc is very user friendly <span aria-label="sweat smile" class="emoji emoji-1f605" role="img" title="sweat smile">:sweat_smile:</span> <a href="https://t.co/Q6rj9mGxbs">https://twitter.com/mycoliza/status/1347688061035896833</a></p><span>- Esteban K – 🦀⚙️@home (@ekuber)</span></div></div>



<a name="227983881"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/async%20vision%20-%20status%20quo/near/227983881" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> tmandry <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/async.20vision.20-.20status.20quo.html#227983881">(Feb 26 2021 at 19:59)</a>:</h4>
<p>This isn't just for tweets – if anyone can think of other documented cases of difficulties or success stories of using async, please drop them here</p>



<a name="227983907"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/async%20vision%20-%20status%20quo/near/227983907" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/async.20vision.20-.20status.20quo.html#227983907">(Feb 26 2021 at 19:59)</a>:</h4>
<p>yes, this is great</p>



<a name="227983918"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/async%20vision%20-%20status%20quo/near/227983918" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/async.20vision.20-.20status.20quo.html#227983918">(Feb 26 2021 at 20:00)</a>:</h4>
<p>thanks <span class="user-mention" data-user-id="116883">@tmandry</span></p>



<a name="228223096"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/async%20vision%20-%20status%20quo/near/228223096" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oliver <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/async.20vision.20-.20status.20quo.html#228223096">(Mar 01 2021 at 12:42)</a>:</h4>
<p><a href="https://meltware.com/2020/10/21/rust-async-nonsense.html">https://meltware.com/2020/10/21/rust-async-nonsense.html</a><br>
<a href="https://vorner.github.io/2020/04/13/hyper-traps.html">https://vorner.github.io/2020/04/13/hyper-traps.html</a><br>
<a href="https://gendignoux.com/blog/2020/12/17/rust-async-type-system-limits.html">https://gendignoux.com/blog/2020/12/17/rust-async-type-system-limits.html</a><br>
<a href="https://www.fpcomplete.com/blog/different-levels-async-rust/">https://www.fpcomplete.com/blog/different-levels-async-rust/</a></p>



<a name="228223358"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/async%20vision%20-%20status%20quo/near/228223358" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oliver <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/async.20vision.20-.20status.20quo.html#228223358">(Mar 01 2021 at 12:44)</a>:</h4>
<p><a href="https://cseweb.ucsd.edu/~yiying/RustStudy-PLDI20.pdf">https://cseweb.ucsd.edu/~yiying/RustStudy-PLDI20.pdf</a><br>
<a href="https://tweedegolf.nl/blog/41/the-promise-of-rust-async-await-for-embedded">https://tweedegolf.nl/blog/41/the-promise-of-rust-async-await-for-embedded</a></p>



<a name="228525425"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/async%20vision%20-%20status%20quo/near/228525425" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> tmandry <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/async.20vision.20-.20status.20quo.html#228525425">(Mar 03 2021 at 02:41)</a>:</h4>
<p>had a great conversation with a team lead for a Fuchsia team who was new to rust and async.. <a href="https://docs.google.com/document/d/1mfMT7NaLMZughKc_SDr71m5Khwmzt9tMUNaYkEz5w_I/edit">transcript is here</a></p>



<a name="228525522"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/async%20vision%20-%20status%20quo/near/228525522" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> tmandry <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/async.20vision.20-.20status.20quo.html#228525522">(Mar 03 2021 at 02:42)</a>:</h4>
<p>(it's quite raw, I plan to bulletize it and add better formatting)</p>



<a name="228541024"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/async%20vision%20-%20status%20quo/near/228541024" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Joshua Nelson <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/async.20vision.20-.20status.20quo.html#228541024">(Mar 03 2021 at 05:52)</a>:</h4>
<p><span class="user-mention silent" data-user-id="116883">tmandry</span> <a href="#narrow/stream/187312-wg-async-foundations/topic/async.20vision.20-.20status.20quo/near/228525425">said</a>:</p>
<blockquote>
<p>had a great conversation with a team lead for a Fuchsia team who was new to rust and async.. <a href="https://docs.google.com/document/d/1mfMT7NaLMZughKc_SDr71m5Khwmzt9tMUNaYkEz5w_I/edit">transcript is here</a></p>
</blockquote>
<blockquote>
<p>apparently File: AsMut&lt;dyn Read&gt; just doesn't hold in general (same for Write)</p>
</blockquote>
<p>I got it to work but only by removing <code>dyn</code> altogether:  <a href="https://play.rust-lang.org/?version=stable&amp;mode=debug&amp;edition=2018&amp;gist=4edfdddebb9b922ac02cb873944df842">https://play.rust-lang.org/?version=stable&amp;mode=debug&amp;edition=2018&amp;gist=4edfdddebb9b922ac02cb873944df842</a></p>



<a name="228541053"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/async%20vision%20-%20status%20quo/near/228541053" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Joshua Nelson <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/async.20vision.20-.20status.20quo.html#228541053">(Mar 03 2021 at 05:52)</a>:</h4>
<p>you can see where I tried to add <code>trait ReadWrite</code> before giving up when the blanket impl conflicted due to orphan rule</p>



<a name="228562270"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/async%20vision%20-%20status%20quo/near/228562270" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/async.20vision.20-.20status.20quo.html#228562270">(Mar 03 2021 at 09:38)</a>:</h4>
<p><span class="user-mention silent" data-user-id="116883">tmandry</span> <a href="#narrow/stream/187312-wg-async-foundations/topic/async.20vision.20-.20status.20quo/near/228525425">said</a>:</p>
<blockquote>
<p>had a great conversation with a team lead for a Fuchsia team who was new to rust and async.. <a href="https://docs.google.com/document/d/1mfMT7NaLMZughKc_SDr71m5Khwmzt9tMUNaYkEz5w_I/edit">transcript is here</a></p>
</blockquote>
<p><span class="user-mention" data-user-id="116883">@tmandry</span> is it possible to include anonymized examples of the code snippets you all are referring to?</p>



<a name="228562814"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/async%20vision%20-%20status%20quo/near/228562814" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/async.20vision.20-.20status.20quo.html#228562814">(Mar 03 2021 at 09:42)</a>:</h4>
<blockquote>
<p>yeah, this team was brand new to rust<br>
straight in the deep end</p>
</blockquote>
<p>this stuck out to me because it's something I've heard a few times</p>



<a name="228639085"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/async%20vision%20-%20status%20quo/near/228639085" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> tmandry <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/async.20vision.20-.20status.20quo.html#228639085">(Mar 03 2021 at 18:10)</a>:</h4>
<p><span class="user-mention silent" data-user-id="116009">nikomatsakis</span> <a href="#narrow/stream/187312-wg-async-foundations/topic/async.20vision.20-.20status.20quo/near/228562270">said</a>:</p>
<blockquote>
<p><span class="user-mention silent" data-user-id="116883">tmandry</span> is it possible to include anonymized examples of the code snippets you all are referring to?</p>
</blockquote>
<p>yeah I can ask for actual examples</p>



<a name="228876096"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/async%20vision%20-%20status%20quo/near/228876096" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/async.20vision.20-.20status.20quo.html#228876096">(Mar 05 2021 at 00:31)</a>:</h4>
<p>I'm going to add some notes from a conversation with 1password into the conversations folder</p>



<a name="229011705"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/async%20vision%20-%20status%20quo/near/229011705" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/async.20vision.20-.20status.20quo.html#229011705">(Mar 05 2021 at 19:35)</a>:</h4>
<p><a href="#narrow/stream/201246-wg-async-foundations.2Fbook/topic/user.20stories/near/228864844">this comment from <span class="user-mention" data-user-id="293524">@jamesmcm</span> seems pretty useful</a></p>



<a name="229758554"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/async%20vision%20-%20status%20quo/near/229758554" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> tmandry <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/async.20vision.20-.20status.20quo.html#229758554">(Mar 10 2021 at 22:25)</a>:</h4>
<p>here's <a href="https://fuchsia-review.googlesource.com/c/fuchsia/+/496879">a bug</a> not caught by the compiler where code failed to use the output of <code>write</code>. technically not async-specific, but worth thinking about as we work to drive <code>AsyncWrite</code> to stabilization.</p>



<a name="229758848"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/async%20vision%20-%20status%20quo/near/229758848" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> tmandry <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/async.20vision.20-.20status.20quo.html#229758848">(Mar 10 2021 at 22:27)</a>:</h4>
<p><a href="https://theta.eu.org/2021/03/08/async-rust-2.html">Why asynchronous Rust doesn't work</a> has a pretty provocative title; it basically says that first-class functions (closures) are hard to use in Rust because of having to use generics and confusing trait bounds, and that the same problems apply to Futures.</p>



<a name="229773601"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/async%20vision%20-%20status%20quo/near/229773601" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Sean McArthur <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/async.20vision.20-.20status.20quo.html#229773601">(Mar 11 2021 at 00:40)</a>:</h4>
<p>So with the adjusted characters (Niklaus being a new programmer, Barbara is an experienced Rust programmer), I'd guess that we could change some of the "writing a library/framework" status quo stories to being from Barbara's POV.</p>



<a name="229779157"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/async%20vision%20-%20status%20quo/near/229779157" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Sean McArthur <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/async.20vision.20-.20status.20quo.html#229779157">(Mar 11 2021 at 01:46)</a>:</h4>
<p>Oh, just found this in the Barbara specific page:</p>
<blockquote>
<p>Lately she's maintaining libraries and frameworks in the async space.</p>
</blockquote>



<a name="229797809"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/async%20vision%20-%20status%20quo/near/229797809" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Matthias247 <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/async.20vision.20-.20status.20quo.html#229797809">(Mar 11 2021 at 05:41)</a>:</h4>
<blockquote>
<p>it basically says that first-class functions (closures) are hard to use in Rust because of having to use generics and confusing trait bounds, and that the same problems apply to Futures.</p>
</blockquote>
<p>There is certainly some truth to that. When I write something along the following (more or less a copy&amp;paste out of our codebase, with adjusted type names), I'm asking myself who else in my team will understand what this really is doing::</p>
<div class="codehilite"><pre><span></span><code>async fn do_something&lt;F, Fut&gt;(func: F) -&gt; Result&lt;(), String&gt;
where
    F: FnOnce(Param1 , Param2) -&gt; Fut + Send + &#39;static,
    Fut: Future&lt;Output = Result&lt;(), String&gt;&gt; + Send + &#39;static,
{
}
</code></pre></div>
<p>Even for me (first generation async user and contributor to standardization) that requires gradually adding trait bounds until the compiler is happy.   And sometimes it doesn't even work, due to lifetimes being extra complicated thanks to lazy evaluation of Futures. <br>
The question is how to improve on this? Adding something along <code>impl async Fn</code>?</p>



<a name="229822019"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/async%20vision%20-%20status%20quo/near/229822019" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Alice Ryhl <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/async.20vision.20-.20status.20quo.html#229822019">(Mar 11 2021 at 09:51)</a>:</h4>
<p>I suppose one could try to define a trait like this:</p>
<div class="codehilite"><pre><span></span><code>trait AsyncFnOnce&lt;Args&gt;
where
    Self::Fut: Future&lt;Output = Self::Output&gt;,
{
    type Fut;
    type Output;

    fn call(self, args: Args) -&gt; Self::Fut;
}
</code></pre></div>
<p>Though it doesn't fully help because your <code>Fut: Send + 'static</code> bound would look pretty ugly when using a trait like the above.</p>



<a name="229923367"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/async%20vision%20-%20status%20quo/near/229923367" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/async.20vision.20-.20status.20quo.html#229923367">(Mar 11 2021 at 20:49)</a>:</h4>
<p><span class="user-mention silent" data-user-id="243965">Sean McArthur</span> <a href="#narrow/stream/187312-wg-async-foundations/topic/async.20vision.20-.20status.20quo/near/229773601">said</a>:</p>
<blockquote>
<p>So with the adjusted characters (Niklaus being a new programmer, Barbara is an experienced Rust programmer), I'd guess that we could change some of the "writing a library/framework" status quo stories to being from Barbara's POV.</p>
</blockquote>
<p>this was my intent, <span class="user-mention" data-user-id="243965">@Sean McArthur</span></p>



<a name="229923627"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/async%20vision%20-%20status%20quo/near/229923627" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/async.20vision.20-.20status.20quo.html#229923627">(Mar 11 2021 at 20:51)</a>:</h4>
<p><span class="user-mention" data-user-id="204219">@Matthias247</span> I'm curious ... to start, I'd have used <code>impl FnOnce</code>...</p>
<div class="codehilite" data-code-language="Rust"><pre><span></span><code><span class="k">async</span><span class="w"> </span><span class="k">fn</span> <span class="nf">do_something</span><span class="o">&lt;</span><span class="n">Fut</span><span class="o">&gt;</span><span class="p">(</span><span class="w"></span>
<span class="w">    </span><span class="n">func</span>: <span class="nc">impl</span><span class="w"> </span><span class="nb">FnOnce</span><span class="p">(</span><span class="n">Param1</span><span class="w"> </span><span class="p">,</span><span class="w"> </span><span class="n">Param2</span><span class="p">)</span><span class="w"> </span>-&gt; <span class="nc">Fut</span><span class="w"> </span><span class="o">+</span><span class="w"> </span><span class="nb">Send</span><span class="w"> </span><span class="o">+</span><span class="w"> </span><span class="o">'</span><span class="nb">static</span><span class="p">,</span><span class="w"></span>
<span class="p">)</span><span class="w"> </span>-&gt; <span class="nb">Result</span><span class="o">&lt;</span><span class="p">(),</span><span class="w"> </span><span class="nb">String</span><span class="o">&gt;</span><span class="w"></span>
<span class="k">where</span><span class="w"></span>
<span class="w">    </span><span class="n">Fut</span>: <span class="nc">Future</span><span class="o">&lt;</span><span class="n">Output</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="nb">Result</span><span class="o">&lt;</span><span class="p">(),</span><span class="w"> </span><span class="nb">String</span><span class="o">&gt;&gt;</span><span class="w"> </span><span class="o">+</span><span class="w"> </span><span class="nb">Send</span><span class="w"> </span><span class="o">+</span><span class="w"> </span><span class="o">'</span><span class="nb">static</span><span class="p">,</span><span class="w"></span>
<span class="p">{</span><span class="w"></span>
<span class="p">}</span><span class="w"></span>
</code></pre></div>
<p>This helps a little but...admittedly not too much. =)</p>



<a name="229923701"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/async%20vision%20-%20status%20quo/near/229923701" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/async.20vision.20-.20status.20quo.html#229923701">(Mar 11 2021 at 20:52)</a>:</h4>
<p>I guess  the question is what parts are most problematic. It's the <code>+ Send + 'static</code> that is particularly verbose, I think?</p>



<a name="229971712"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/async%20vision%20-%20status%20quo/near/229971712" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Matthias247 <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/async.20vision.20-.20status.20quo.html#229971712">(Mar 12 2021 at 03:52)</a>:</h4>
<p>Well that is verbose. But I think for most people it's not even obvious that for passing an async function (what they want), you instead of have to pass a function which creates a <code>Future</code>. The <code>Future</code> is the implementation detail, but directly leaks to the user. In Kotlin  (which was mentioned in the parallel thread), you users would just do the more obvious</p>
<div class="codehilite"><pre><span></span><code>suspend fun do_something(func: suspend (Param1, Param2) -&gt; Result&lt;(), String&gt;) {
}
</code></pre></div>
<p>Once people understand the basic transformation the lifetimes start to add an extra challenge.</p>



<a name="230009429"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/async%20vision%20-%20status%20quo/near/230009429" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/async.20vision.20-.20status.20quo.html#230009429">(Mar 12 2021 at 10:53)</a>:</h4>
<p><span class="user-mention" data-user-id="204219">@Matthias247</span> ah! yes, of course</p>



<a name="230009455"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/async%20vision%20-%20status%20quo/near/230009455" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/async.20vision.20-.20status.20quo.html#230009455">(Mar 12 2021 at 10:53)</a>:</h4>
<p>So <del>many things wrong here</del> much room for improvement here :)</p>



<a name="230917102"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/async%20vision%20-%20status%20quo/near/230917102" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Sean McArthur <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/async.20vision.20-.20status.20quo.html#230917102">(Mar 18 2021 at 18:39)</a>:</h4>
<p>Ok, here's a story of "Alan hates writing a <code>Stream</code>": <a href="https://github.com/rust-lang/wg-async-foundations/pull/48">https://github.com/rust-lang/wg-async-foundations/pull/48</a></p>



<a name="230948324"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/async%20vision%20-%20status%20quo/near/230948324" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Frederik Baetens <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/async.20vision.20-.20status.20quo.html#230948324">(Mar 18 2021 at 22:40)</a>:</h4>
<p>I also made a story about an async newcomer's experience. <span aria-label="smile" class="emoji emoji-1f642" role="img" title="smile">:smile:</span></p>
<p><a href="https://github.com/rust-lang/wg-async-foundations/pull/56">https://github.com/rust-lang/wg-async-foundations/pull/56</a></p>



<a name="230949591"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/async%20vision%20-%20status%20quo/near/230949591" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Alice Ryhl <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/async.20vision.20-.20status.20quo.html#230949591">(Mar 18 2021 at 22:54)</a>:</h4>
<p><span class="user-mention" data-user-id="398861">@Frederik Baetens</span>  If you still have any questions about the stuff you mentioned in your post, I'll be happy to answer them.</p>



<a name="230951457"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187312-wg-async-foundations/topic/async%20vision%20-%20status%20quo/near/230951457" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Frederik Baetens <a href="https://rust-lang.github.io/zulip_archive/stream/187312-wg-async-foundations/topic/async.20vision.20-.20status.20quo.html#230951457">(Mar 18 2021 at 23:14)</a>:</h4>
<p>I'll come by in the Tokio discord sometime tomorrow perhaps (its already a bit late), but i'd just like to say that  I think blog posts of yours like this one are great! <a href="https://ryhl.io/blog/actors-with-tokio/">https://ryhl.io/blog/actors-with-tokio/</a></p>
<p>It discusses how to implement a design pattern (actors) with async. I'd love to see a lot more of this floating around in the community.</p>
<p>Previously I also loved sections of the book like this: <a href="https://doc.rust-lang.org/book/ch17-03-oo-design-patterns.html#trade-offs-of-the-state-pattern">https://doc.rust-lang.org/book/ch17-03-oo-design-patterns.html#trade-offs-of-the-state-pattern</a> which went in depth about the tradeoffs of design patterns from other languages, and how to successfully adapt them to Rust, together with new, great design patterns which are also usable outside of Rust. I'd love to see similar things for async!</p>
<p>Also thanks for your comment on my pr, i changed the wording slightly to avoid confusion <span aria-label="smile" class="emoji emoji-1f642" role="img" title="smile">:smile:</span></p>



<hr><p>Last updated: Aug 07 2021 at 22:04 UTC</p>
</html>